//
//  MainTabBarController.m
//  XiJianChui
//
//  Created by aaa on 16/7/18.
//  Copyright © 2016年 FanShuHan. All rights reserved.
//

#import "MainTabBarController.h"
#import "MainNavigationController.h"
#import "NearByViewController.h"
#import "HomerViewController.h"
#import "ShopViewController.h"
#import "ShowViewController.h"

@interface MainTabBarController ()

@end

@implementation MainTabBarController
+ (void)load
{
    // 获取哪个类中UITabBarItem
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
    
    // 设置按钮选中标题的颜色:富文本:描述一个文字颜色,字体,阴影,空心,图文混排
    // 创建一个描述文本属性的字典
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor blackColor];
    [item setTitleTextAttributes:attrs forState:UIControlStateSelected];
    
    // 设置字体尺寸:只有设置正常状态下,才会有效果
    NSMutableDictionary *attrsNor = [NSMutableDictionary dictionary];
    attrsNor[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    [item setTitleTextAttributes:attrsNor forState:UIControlStateNormal];

}
#pragma mark - 生命周期方法
- (void)viewDidLoad {
    [super viewDidLoad];
    // 1 添加子控制器(5个子控制器) -> 自定义控制器 -> 划分项目文件结构
    [self setupAllChildViewController];
    
    // 2 设置tabBar上按钮内容 -> 由对应的子控制器的tabBarItem属性
    [self setupAllTitleButton];
    
    
}
#pragma mark - 添加所有子控制器
- (void)setupAllChildViewController
{
    // 附近
    NearByViewController *nearByVc = [[NearByViewController alloc] init];
    MainNavigationController *nav = [[MainNavigationController alloc] initWithRootViewController:nearByVc];
    [self addChildViewController:nav];
    
    // 附近
    ShowViewController *showVc = [[ShowViewController alloc] init];
    MainNavigationController *nav1 = [[MainNavigationController alloc] initWithRootViewController:showVc];
    [self addChildViewController:nav1];
    
    // 店铺
    ShopViewController *shopVc = [[ShopViewController alloc] init];
    MainNavigationController *nav2 = [[MainNavigationController alloc] initWithRootViewController:shopVc];
    [self addChildViewController:nav2];
    
}
#pragma mark - 设置tabBar上所有按钮内容
- (void)setupAllTitleButton
{
    UINavigationController *nav = self.childViewControllers[0];
    nav.tabBarItem.title = @"附近";
    nav.tabBarItem.image = [UIImage imageNamed:@"tabBar_me_icon"];
    nav.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_me_click_icon"];
    
    UINavigationController *nav1 = self.childViewControllers[1];
    nav1.tabBarItem.title = @"主页";
    nav1.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];
    nav1.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_essence_click_icon"];
    
    UINavigationController *nav2 = self.childViewControllers[2];
    nav2.tabBarItem.title = @"店铺";
    nav2.tabBarItem.image = [UIImage imageNamed:@"tabBar_friendTrends_icon"];
    nav2.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_friendTrends_click_icon"];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
